/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.tspp.professionAccounter;

import com.tspp.dao.DaoException;
import com.tspp.dao.DaoFactory;
import com.tspp.dao.SpecialityDao;
import com.tspp.dao.dto.Speciality;
import java.util.List;

/**
 * Class that represents functionality of professionAccounter user
 * @author Maks
 */
public class ProfessionAccounterBean {

    /**
     * Get all speciality
     * @return list of specialities
     * @throws DaoException
     */
    public List<Speciality> getSpecialities() throws DaoException {
        SpecialityDao dao = DaoFactory.getSpecialityDao();
        return dao.findAll();
    }

    /**
     * Add new speciality
     * @param spec new speciality
     * @throws DaoException
     */
    public void addSpeciality(Speciality spec) throws DaoException {
        SpecialityDao dao = DaoFactory.getSpecialityDao();
        dao.insert(spec);
    }

    /**
     * Delete specified speciality
     * @param id id of speciality to delete
     * @throws DaoException
     */
    public void deleteSpeciality(int id) throws DaoException {
        SpecialityDao dao = DaoFactory.getSpecialityDao();
        dao.delete(id);
    }

    /**
     * Update specified speciality
     * @param id id of speciality to update
     * @param spec
     * @throws DaoException
     */
    public void updateSpeciality(int id, Speciality spec) throws DaoException {
        SpecialityDao dao = DaoFactory.getSpecialityDao();
        dao.update(id, spec);
    }

}
